/* @flow */


import { initExtend } from './extend'
import { nextTick } from '../util/next-tick'
import { extend } from '../../util/index'
import { mergeOptions } from '../util/options'
import { defineReactive, observe } from '../observer/index'
import { initUse } from './use'
import { initAssetRegisters } from './assets'
import { ASSET_TYPES } from '../../util/constants'
import builtInComponents from '../component/index'


export function initGlobalAPI(Vue) {
  // config
  //   const configDef = {}
  //   configDef.get = () => config
  //   Object.defineProperty(Vue, 'config', configDef)


  Vue.util = {
    extend,
    mergeOptions,
    defineReactive
  }

  Vue.nextTick = nextTick

  Vue.observable = (obj) => {
    return observe(obj)
  }

  Vue.options = Object.create(null)
  ASSET_TYPES.forEach(type => {
    Vue.options[type + 's'] = Object.create(null)
  })

  Vue.options._base = Vue

  //把keep-alive组件添加到全局属性components里面
  extend(Vue.options.components, builtInComponents)

  initUse(Vue)
  //   initMixin(Vue)
  initExtend(Vue)
  initAssetRegisters(Vue)
}
